using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class TK_Station
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Code { get; set; }
        public int CountryID { get; set; }
        public string CountryName { get; set; }
        public string StationTo { get; set; }
        public bool IsDeleted { get; set; }

        #region TK_StationSelectAll
        public static List<TK_Station> TK_StationSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.TK_Station.TK_StationSelectAll(strSearch,top,bottom,ConnectionString);
            List<TK_Station> TK_StationList = new List<TK_Station>();
            while(dr.Read())
            {
                TK_Station myTK_Station = new TK_Station
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    Code = !dr.IsDBNull(dr.GetOrdinal("Code")) ? (string)dr["Code"] : null,
                    CountryID = !dr.IsDBNull(dr.GetOrdinal("CountryID")) ? (int)dr["CountryID"] : 0,
                    CountryName = !dr.IsDBNull(dr.GetOrdinal("CountryName")) ? (string)dr["CountryName"] : null,
                    StationTo = !dr.IsDBNull(dr.GetOrdinal("StationTo")) ? (string)dr["StationTo"] : null,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                TK_StationList.Add(myTK_Station);
        }
        dr.Close();
        dr.Dispose();
        return TK_StationList;
        }
        #endregion
        #region TK_StationSelectRow
        public static TK_Station TK_StationSelectRow(int ID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.TK_Station.TK_StationSelectRow(ID, ConnectionString);
            TK_Station tk_station = null;

            if(dr.Read())
            {
                tk_station= new TK_Station
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    Code = !dr.IsDBNull(dr.GetOrdinal("Code")) ? (string)dr["Code"] : null,
                    CountryID = !dr.IsDBNull(dr.GetOrdinal("CountryID")) ? (int)dr["CountryID"] : 0,
                    CountryName = !dr.IsDBNull(dr.GetOrdinal("CountryName")) ? (string)dr["CountryName"] : null,
                    StationTo = !dr.IsDBNull(dr.GetOrdinal("StationTo")) ? (string)dr["StationTo"] : null,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,

                };
            }
        dr.Close();
        dr.Dispose();
        return tk_station;
        }
        #endregion
        #region TK_StationInsertRow
        public static void TK_StationInsertRow(int ID, string Name, string Code, int CountryID, string CountryName, string StationTo, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.TK_Station.TK_StationInsertRow(ID, Name, Code, CountryID, CountryName, StationTo, IsDeleted, ConnectionString);
        }
        #endregion
        #region TK_StationUpdateRow
        public static void TK_StationUpdateRow(int ID, string Name, string Code, int CountryID, string CountryName, string StationTo, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.TK_Station.TK_StationUpdateRow(ID, Name, Code, CountryID, CountryName, StationTo, IsDeleted, ConnectionString);
        }
        #endregion
        #region TK_StationDeleteRow
        public static void TK_StationDeleteRow(int ID, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.TK_Station.TK_StationDeleteRow(ID,ConnectionString);
        }
        #endregion
    }
}
